#define IMPLEMENT_API
#include <hx/CFFI.h>
#include <hxcpp.h>

extern "C" {

	// used to add random chats to an NPC
	// This data may be stored in the DB at a later revision of the code
	// ok, so this fct adds to npc @param id, a chat line that will fire with
	// a probability of @param pct with each chat given a % weight between
	// @param minp and @param maxp with the chat of @param msg
	// The @param msg can be started with an apostrophe (') to indicate a 'say'
	// or a /me for a custom emote. Preface the message with the 'at' symbol
	// (@) followed by the social to emite a social (@cheer or @thank)
	void __add_npc_random_chatter(value id, value /* int */ pct, value minp, value maxp, value msg)
	{

	}

	// used to move @param charID to room @param exit
	value /* entity_t */ __move_character(value charID, value exit)
	{
		return alloc_int(0);
	}

	// used to add arbitrary @param key / @param val pairs to an object
	void __add_object_property(value id, value key, value val)
	{

	}

	// used to add @param adj to a descriptive set of an object
	void __add_object_adjective(value id, value adj)
	{

	}

	// sets the Also Known As (aka aka aliases)
	void __add_object_aka(value id, value aka)
	{

	}

	// @param s
	// @param d
	// @func add_spell
	// @brief used to add a magick spell to a PC or NPC
	value __add_spell(value /*const char * */ s, value /* const char * */ d) {

		return alloc_int(0);

	}

	// @param c
	// @function add_command
	// @brief used to add a command (usu. temporarily) to an object
	// or person/character/NPC
	value __add_command(value /*const char * */ c)
	{
		const char * msg = "__add_command(value c) ";
		char buff[32];

		sprintf(buff,"%s:%s", msg, val_get_string(c));
		return alloc_string(buff);
//		return alloc_int(0);
	}

	// used to add an actionable (yet intangible) item to a room
	// ex. add_actionable_item("look","crate", "This is a rather unordinary crate made of wood.");
	// @param name can contain adjectives ie. "wooden crate" and it will match all
	void __add_actionable_item(value /* const char */ cmd, value /*const char */ name, value /*const char */ val)
	{

	}

	// this function is used to add periodic random chatter to a room
	// @param mini minimum interval
	// @param maxi maximum interval
	 // @param chats a RandomObject containing % chance a chat will be selected
	void __add_room_chat(value /* int */ mini, value /* int */ maxi, value /* RandomObject */ chats)
	{

	}

	// returns the id of the newly created exit
	value /* entity_t */ __add_room_exit(value thisRoom, value destRoom, value name)
	{

		return alloc_int(0);
	}

	// this is different from getting information about the room or portals or
	// whatever, because characters/mobiles are not stored in the db so we
	// have to get them from the live objects in core memory
	value /* array<entity_t> */ __get_room_chars(value /* entity_t */ roomID)
	{
		return alloc_array(0);
	}


	// @param i
	// @param msg
	// Used to send a message to an object
	value __tell_object(value i, value msg) {
		if (!val_is_int(i)) return val_null;

		return alloc_int(0);
	}


	// @param p
	// Used to check if an object or character can do something, indicated
	// by a "can_<action>" policy check
	value __check_policy(value /* const char * */ p)
	{
		return alloc_bool(true);
	}

	// use this function to add chatter upon getting attacked or hit
	void __add_npc_attack_chatter(value id, value pct, value minp, value maxp, value msg)
	{

	}

	// use this function to randomly select a response from array @param resp
	// in response to hearing keywords @param keyw in the room
	void __add_npc_chat_response(value /* array */ keyw, value /* array */ resp)
	{

	}


}

DEFINE_PRIM(__add_spell,2);
DEFINE_PRIM(__add_command,1);
DEFINE_PRIM(__tell_object,2);
DEFINE_PRIM(__check_policy,1);
DEFINE_PRIM(__add_room_exit,3);
DEFINE_PRIM(__add_room_chat,3);
DEFINE_PRIM(__add_actionable_item,3);
DEFINE_PRIM(__add_object_property,3);
DEFINE_PRIM(__add_object_adjective,2);
DEFINE_PRIM(__add_object_aka,2);
DEFINE_PRIM(__get_room_chars,1);
DEFINE_PRIM(__move_character,2);
DEFINE_PRIM(__add_npc_random_chatter,5);
DEFINE_PRIM(__add_npc_attack_chatter,5);
DEFINE_PRIM(__add_npc_chat_response,4);
//DEFINE_PRIM();
//DEFINE_PRIM();




